(function(){"use strict";BX.namespace("BX.Landing");var t=BX.Landing.Utils.trim;var e=BX.Landing.Utils.isPlainObject;var i=BX.Landing.Utils.isString;var n=BX.Landing.Utils.textToPlaceholders;var a=BX.Landing.Utils.create;var s=BX.Landing.Utils.escapeText;var d=BX.Landing.Utils.decodeDataValue;BX.Landing.Block.Node.Link=function(t){BX.Landing.Block.Node.apply(this,arguments);this.type="link";if(!this.isGrouped()){this.node.addEventListener("click",this.onClick.bind(this))}if(this.isAllowInlineEdit()){this.node.setAttribute("title",BX.Landing.Loc.getMessage("LANDING_TITLE_OF_LINK_NODE"))}this.onChange=BX.Runtime.debounce(this.onChange,500);this.onContentUpdate=BX.Runtime.debounce(this.onContentUpdate,500)};BX.Landing.Block.Node.Link.prototype={__proto__:BX.Landing.Block.Node.prototype,constructor:BX.Landing.Block.Node.Link,onContentUpdate:function(){BX.Landing.History.getInstance().push();this.getField().setValue(this.getValue())},isMenuMode:function(){return this.manifest.menuMode===true},onClick:function(t){t.preventDefault();if(!this.isMenuMode()){t.stopPropagation()}if(this.isAllowInlineEdit()){BX.Landing.UI.Button.ColorAction.hideAll();if(!BX.Landing.UI.Panel.StylePanel.getInstance().isShown()){BX.Landing.UI.Panel.Link.getInstance().show(this)}}},isPrevented:function(){return this.getValue().target==="_popup"},setValue:function(t,e,n){this.startValue=this.startValue||this.getValue();this.preventSave(e);if(!this.containsImage()&&this.isAllowInlineEdit()){var a=this.getField(true).hrefInput;if(i(t.text)&&t.text.includes("{{name}}")){a.getPlaceholderData(t.href).then(function(e){this.node.innerHTML=t.text.replace(new RegExp("{{name}}"),'<span data-placeholder="name">'+e.name+"</span>")}.bind(this))}else{if(!this.getField().containsHtml()&&!this.manifest.skipContent){this.node.innerHTML=s(t.text)}}}this.node.setAttribute("href",d(t.href));this.node.setAttribute("target",s(t.target));if("attrs"in t){for(var r in t.attrs){if(t.attrs.hasOwnProperty(r)){this.node.setAttribute(r,t.attrs[r])}}}else{this.node.removeAttribute("data-url");this.node.removeAttribute("data-embed")}this.onChange(n);if(!n){this.onContentUpdate()}},containsImage:function(){return!!this.node.firstElementChild&&this.node.firstElementChild.tagName==="IMG"},getValue:function(){var i={text:n(t(this.node.innerHTML)),href:t(this.node.getAttribute("href")),target:t(this.node.getAttribute("target")||"_self")};if(this.node.getAttribute("data-url")){i.attrs={"data-url":t(this.node.getAttribute("data-url"))}}if(this.node.getAttribute("data-dynamic")){if(!e(i.attrs)){i.attrs={}}i.attrs["data-dynamic"]=this.node.getAttribute("data-dynamic")}if(this.manifest.skipContent){i["skipContent"]=true;delete i.text}if(i.href&&i.href.startsWith("selectActions:")){i.href="#"}return i},getField:function(t){var e=this.getValue();e.text=n(a("div",{html:e.text}).innerHTML);if(!this.field){var i=[BX.Landing.UI.Field.LinkUrl.TYPE_BLOCK,BX.Landing.UI.Field.LinkUrl.TYPE_PAGE,BX.Landing.UI.Field.LinkUrl.TYPE_CRM_FORM,BX.Landing.UI.Field.LinkUrl.TYPE_CRM_PHONE];if(BX.Landing.Main.getInstance().options.params.type===BX.Landing.Main.TYPE_STORE){i.push(BX.Landing.UI.Field.LinkUrl.TYPE_CATALOG)}if(BX.Landing.Main.getInstance().options.features.includes("diskFile")){i.push(BX.Landing.UI.Field.LinkUrl.TYPE_DISK_FILE)}this.field=new BX.Landing.UI.Field.Link({title:this.manifest.name,selector:this.selector,skipContent:this.manifest.skipContent,content:e,options:{siteId:BX.Landing.Main.getInstance().options.site_id,landingId:BX.Landing.Main.getInstance().id},allowedTypes:i})}else{if(!t){this.field.setValue(e);this.field.content=e;this.field.hrefInput.content=e.href;this.field.hrefInput.makeDisplayedHrefValue();this.field.hrefInput.setHrefTypeSwitcherValue(this.field.hrefInput.getHrefStringType());this.field.hrefInput.removeHrefTypeFromHrefString()}}return this.field}}})();
//# sourceMappingURL=link.map.js